package mtblreader;

import mtbldomain.MetricDescriptionType;

public class ProjectDetail {

	public static final Integer DEFAULT_REVISION_NUMBER = 0;
	
	private String fileName;
	private MetricDescriptionType metricDescriptionType;
	private Integer revisionNumber = DEFAULT_REVISION_NUMBER;

	public String getFileName() {
		return fileName;
	}

	public void setFileName(String fileName) {
		this.fileName = fileName;
	}

	public MetricDescriptionType getMetricDescriptionType() {
		return metricDescriptionType;
	}

	public void setMetricDescriptionType(
			MetricDescriptionType metricDescriptionType) {
		this.metricDescriptionType = metricDescriptionType;
	}

	public Integer getRevisionNumber() {
		return revisionNumber;
	}

	public void setRevisionNumber(Integer revisionNumber) {
		this.revisionNumber = revisionNumber;
	}

	@Override
	public boolean equals(Object other) {
		if (this == other)
			return true;
		if (other.getClass() != this.getClass())
			return false;

		ProjectDetail otherProjectDetail = (ProjectDetail) other;
		if (hasSameFile(otherProjectDetail) && hasSameProjectName(otherProjectDetail)) {
			return true;
		}
		return false;
	}

	@Override
	public int hashCode() {
		int hash = 1;
		hash = hash * 31 + getFileName().hashCode();
		hash = hash * 31 + getMetricDescriptionType().getFqname().hashCode();
		return hash;
	}

	public boolean hasSameFile(ProjectDetail project) {
		if (this.fileName.equals(project.fileName)) {
			return true;
		}
		return false;
	}

	public boolean hasSameProjectName(ProjectDetail project) {
		if (this.metricDescriptionType.getProjectName().equals(
				project.getMetricDescriptionType().getProjectName())) {
			return true;
		}
		return false;
	}
	
	public boolean hasSameRevisionNumber(ProjectDetail project){
		if(this.getRevisionNumber().equals(project.getRevisionNumber()))
			return true;
		return false;
	}
	
}
